#encoding=utf-8
from threading import Thread
import random
import time
from Queue import Queue
in_num_thread=10
out_num_thread=10
in_queue=Queue()
out_queue=Queue()
def listSuites(suites):
    for suite in suites:
        in_queue.put(suite)
def readSuites(iq,in_queue):
    suites=[]
    while True:
        suite=in_queue.get()
        for s in suite:
            suites.append(s)
        out_queue.put(suites)
        in_queue.task_done()
def writeSuites(oq,out_queue):
    
    while True:
        suitelist=out_queue.get()
        #runner.run(suitelist)
        print suitelist
        out_queue.task_done()
        
def run(suites):
    listSuites(suites)
    for iq in range(in_num_thread):
        worker=Thread(target=readSuites,args=(iq,in_queue))
        worker.setDaemon(True)
        worker.start()
    in_queue.join()
    
    for oq in range(out_num_thread):
        worker=Thread(target=writeSuites,args=(iq,in_queue))
        worker.setDaemon(True)
        worker.start()
    out_queue.join()
if __name__=="__main__":
    print('starting at:',time.ctime())
    suites=[1,2,3,4,5]
    run(suites)
    print('ending at:',time.ctime()) 